﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;

namespace LenderClearingHouse
{
    public partial class RentProjectionUnitEditControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.DataBinding += new EventHandler(RentProjectionUnitEditControl_DataBinding);
        }

        protected void FillBed()
        {
            edBedrooms.Items.Clear();
            for (int i = 1; i <= 20; i++)
            {
                edBedrooms.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));
            }
            
        }

        protected void RentProjectionUnitEditControl_DataBinding(object sender, EventArgs e)
        {
            FillBed();
        }

        object _dataItem = null;

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
                edAPN.Text = (Page as RentProjectionUnit).Apn;
                edPropertyLocation.Text = (Page as RentProjectionUnit).PropertyLocation;

                FillBed();
                edBedrooms.SelectedIndex = 0;
                if ((value != null) && !(value is Telerik.Web.UI.GridInsertionObject))
                {
                    DataRowView drv = (DataRowView)value;
                    Utilities.SetValueToCombo(edBedrooms, drv["Bedrooms"]);
                }
            }
        }
    }
}